<?php
$controller = substr($active, 0, strlen($active) - 2);
if ($page_total <= 5) {
	$first_index = 1;
	$last_index = $page_total;
} else {
	$first_index = $page_current - 2;
	$last_index = $page_current + 2;
}
while ($first_index < 1) {
	$first_index++;
	$last_index++;
}
while ($last_index > $page_total) {
	$first_index--;
	$last_index--;
}
?>
<center>
<ul class="pagination">
<li id="page-front">
<?php echo anchor(site_url($controller . '?page=1'), '&laquo;');?>
</li>
<?php
for ($i = $first_index; $i <= $last_index; $i++) {
	echo '<li id="page-' . $i . '">';
	echo anchor($controller . '?page=' . $i, $i);
	echo '</li>';
}
?>
<!--<li><a href="#">1</a></li>
  <li><a href="#">2</a></li>
  <li><a href="#">3</a></li>
  <li><a href="#">4</a></li>
  <li><a href="#">5</a></li>-->
  <li id="page-rear">
<?php echo anchor(site_url($controller . '?page=' . $page_total), '&raquo;');?></li>
</ul>
</center>
<script>
$(document).ready(function(){
$('li#page-<?php echo $page_current;?>').addClass('active');
});
</script>
